package com.lightjet.macross.base.feign.api.remoteclient;

import com.lightjet.macross.base.feign.api.config.JWTFeignConfig;
import com.lightjet.macross.base.feign.api.domain.AuthUser;

import com.lightjet.macross.base.feign.api.dto.upms.ApiRulesDTO;
import com.lightjet.macross.base.feign.api.dto.upms.DeptViewClientDTO;
import com.lightjet.macross.base.feign.api.dto.upms.UserViewClientDTO;
import com.lightjet.macross.common.dto.ResponseDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "base-upms",configuration = JWTFeignConfig.class) // url = "http://10.122.128.83:8999/base-upms"
public interface BaseUPMSRemoteClient {

    @GetMapping(value = "/api/org/dept/all")
    ResponseDTO<List<DeptViewClientDTO>> GetAllDepts();

    @GetMapping(value = "/api/org/dept")
    ResponseDTO<DeptViewClientDTO> GetDept(@RequestParam(name = "id") String id, @RequestParam(name = "code", defaultValue = "*", required = false) String code);

    @RequestMapping(value = "/api/user/current", method = {RequestMethod.GET})
    ResponseDTO<UserViewClientDTO> Current(@ModelAttribute("CurrentUser") AuthUser user);

    @GetMapping("/api/user")
    ResponseDTO<UserViewClientDTO> GetUser(@RequestParam(name = "id") String id, @RequestParam(name = "username", required = false) String username);

    @GetMapping("/api/user/displayname")
    ResponseDTO<UserViewClientDTO> GetUserByDisplayname(@RequestParam(name = "displayname") String displayname);

    @GetMapping("/api/user/adapter")
    ResponseDTO<AuthUser> GetUserBySystem(@RequestParam(name = "id") String id,@RequestParam(name = "beanname", required = false) String beanname);

    @GetMapping("/api/user/all")
    ResponseDTO<List<UserViewClientDTO>> GetAllUsers();

    @GetMapping("/api/user/dept")
    ResponseDTO<List<UserViewClientDTO>> GetUsersByDeptId(@RequestParam(name = "id", required = false) String id); //,@ModelAttribute("CurrentUser") AuthUser user);

    @GetMapping("/api/user/page")
    ResponseDTO<Page<UserViewClientDTO>> GetUsersPagedByFilters(@RequestParam(name = "dispname", required = false) String dispname, @RequestParam(name = "uname",required = false) String uname, @RequestParam(name="workno",required = false) String workno, @RequestParam(name="orgid",required = false) String orgid, @RequestParam(name="pageSize") Integer pageSize, @RequestParam(name="pageNumber") Integer pageNumber);

     @GetMapping("/api/user/role")
    ResponseDTO<List<UserViewClientDTO>> GetUsersByRole(//@RequestHeader(name = "exchange-token", required = false) String token,
                                                        @RequestParam("systemshortname") String systemshortname, @RequestParam(name = "deptid", defaultValue = "-1") Integer deptid, @RequestParam(name = "rolecode", required = false) String rolecode, @RequestParam(name = "rolename", required = false) String rolename);
    /**/

    //ResponseDTO<List<ResourceInfo>> GetResourceByUserAndSystem(String userkey, String systemshortname, @ModelAttribute("CurrentUser") AuthUser user);

    //ResponseDTO<List<AdminLTEMenuDTO>> GetResourceTreeByUserAndSystem(String userkey, String systemshortname, @ModelAttribute("CurrentUser") AuthUser user);

    //鉴权API
    @GetMapping("/api/apirules/uri")
    ResponseDTO<ApiRulesDTO> GetRuleByPath(@RequestParam("servicename") String servicename, @RequestParam("acturi") String acturi);
}
